package com.example.vue_shop.config.error;

import com.example.vue_shop.utils.ResultObj;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author lipengwei
 */
@ControllerAdvice
public class MyExceptionAdvice {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResultObj<String> customException(Exception e) {
        ResultObj<String> baseResponse = new ResultObj<>();
        System.out.println("捕捉到异常！！！！！=" + e.getMessage());
        baseResponse.setMessage(e.getMessage());

        Assert.isNull("","");
        return baseResponse;
    }
}
